/*
 * Copyright (C) 2012-2016 Markus Junginger, greenrobot (http://greenrobot.org)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.voilet.interview.open.eventbus;


import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
//命名为 java doc 文档
@Documented
//指定在运行时有效，即在运行时能保持这个 Subscribe
@Retention(RetentionPolicy.RUNTIME)
//指定类型为 METHOD，表名用来描述方法
@Target({ElementType.METHOD})
public @interface Subscribe {
    //指定线程模式，可以指定在 Subscribe 中接收的 Event 所处的线程
    ThreadMode threadMode() default ThreadMode.POSTING;

    /**
     * If true, delivers the most recent sticky event (posted with
     * {@link EventBus#postSticky(Object)}) to this subscriber (if event available).
     */
    //粘性事件是事件消费者在事件发布之后才注册，依然能接收到该事件的特殊类型。
    //StickyEvent 与普通 Event的 普通就在于，EventBus 会自动维护被作为 StickyEvent 被 post 出来
    // （即在发布事件时使用 EventBus.getDefault().postSticky(new MyEvent()) 方法）的事件的最后一个副本在缓存中。
    // 任何时候在任何一个订阅了该事件的订阅者中的任何地方，都可以通 EventBus.getDefault().getStickyEvent(MyEvent.class)
    // 来取得该类型事件的最后一次缓存。
    boolean sticky() default false;

    /** Subscriber priority to influence the order of event delivery.
     * Within the same delivery thread ({@link ThreadMode}), higher priority subscribers will receive events before
     * others with a lower priority. The default priority is 0. Note: the priority does *NOT* affect the order of
     * delivery among subscribers with different {@link ThreadMode}s! */
    //priority 是 Method 的优先级，优先级高的可以先获得分发事件的权利。这个不会影响不同的 ThreadMode 的分发事件顺序。
    int priority() default 0;
}

